package edu.centenary.assignmenttracker;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AssignAdapter extends ArrayAdapter<Assignment> {
	
	private ArrayList<Assignment> alist;
	private Context myContext;

	public AssignAdapter(Context context, int resource, ArrayList<Assignment> alist) {
		super(context, resource, alist);
		this.alist = alist;
		this.myContext = context;
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		if(convertView == null){
			LayoutInflater vi = (LayoutInflater)myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = vi.inflate(R.layout.row, null);
		}
		
		Assignment which = alist.get(position);
		
		if(which != null){
			TextView top = (TextView)convertView.findViewById(R.id.top);
			top.setText(which.getName());
			TextView b = (TextView)convertView.findViewById(R.id.bottom);
			b.setText(which.getdate());
		}
		
		return convertView;
	}

}
